from django.contrib.postgres.fields import ArrayField
from django.db import models


class Product(models.Model):
    name = models.CharField(max_length=100, db_index=True)  # 添加索引加速查询
    sku = models.CharField(max_length=20, unique=True)
    unit_price = models.DecimalField(max_digits=10, decimal_places=2)
    stock = models.IntegerField(default=0)
    tags = ArrayField(models.CharField(max_length=32), blank=True)  # PostgreSQL数组字段
    specifications = models.JSONField()  # 存储动态规格参数
